using System;

namespace StatePatternDemo
{
    public interface IWorkState
    {
        void HandleWorkState(Employee emp);
    }

    public class Leaving:IWorkState
    {
        public void HandleWorkState(Employee emp)
        {
            System.Console.WriteLine($"{emp.Name} 请假 {emp.LeavingDays} 天");
            System.Console.WriteLine($"{emp.Name} 上次请假日期是 {emp.LastLeavingDate} ");
        }
    }

    public class Working:IWorkState
    {
        public void HandleWorkState(Employee emp)
        {
            System.Console.WriteLine($"{emp.Name} 正常上班中...");
            System.Console.WriteLine($"{emp.Name} 已连续工作 {Datetime.Now.Day - LastLeavingDate} 天");
        }

    }

    public class Employee
    {
        public string Name { get; set; }

        public double LeavingDays { get; set; }
        public Datetime LastLeavingDate { get; set; }
        public double TotalLeavingDays { get; set; }

        public double WorkingDays { get; set; }

        private IWorkState WorkState;

        public Employee(IWorkState workState)
        {
            this.WorkState = workState;
        }

        public void SetState(IWorkState workState)
        {
            this.WorkState = workState;
        }

        /// <code>
        /// 上班签到或请假导致的状态改变
        /// </code>
        public void WorkingStateChanging(Employee emp)
        {
            this.WorkState.HandleWorkState(Employee emp);
        }
    }
}